package com.xiaomi.service.impl;

import com.xiaomi.entity.Details;
import com.xiaomi.mapper.DetailsMapper;
import com.xiaomi.mapper.OrderMapper;
import com.xiaomi.service.DetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @ClassName DetailsServiceImpl
 * @Description TODO
 * @Author WL
 * @Date 2021/12/1 19:30
 * @Version 1.0
 **/
@Service
public class DetailsServiceImpl implements DetailsService {
    @Autowired
    private DetailsMapper detailsMapper;
    @Autowired
    private OrderMapper orderMapper;
    @Override
    public List<Details> pageSearch(Map<String,Object> pars) {
        List<Details> detList=detailsMapper.selectAll(pars);

        for (Details det:detList){
            det.setDing(orderMapper.selectType(det.getId()));
        }
        return detList;
    }

    @Override
    public Integer getCount(Map<String,Object> pars) {
        return detailsMapper.getCount(pars);
    }

    @Override
    @Transactional
    public void insert(Details details) {
        detailsMapper.insert(details);
    }

    @Override
    @Transactional
    public void update(Details details) {
detailsMapper.update(details);
    }

    @Override
    public Integer delete(Integer id) {
        return detailsMapper.delete(id);
    }
}
